package com.ajx.abui.dialog;


import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ajx.abui.R;
import com.bumptech.glide.Glide;

/**
 * Created by lai on 2017/9/9.
 */

public class EmptyView extends RelativeLayout{

    private ImageView imageView;
    private TextView loadingText,errorText;
    private OnErrorClickListener onErrorClickListener;
    public void setOnErrorClickListener(OnErrorClickListener onErrorClickListener) {
        this.onErrorClickListener = onErrorClickListener;
    }



    public EmptyView(Context context) {
        this(context, null);
    }

    public EmptyView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    private void initView() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.empty, this, true);
        imageView = ((ImageView) view.findViewById(R.id.iv_image));
        loadingText=(TextView) view.findViewById(R.id.tv_loading);
        errorText=(TextView)view.findViewById(R.id.tv_error);
        errorText.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onErrorClickListener!=null){
                    onErrorClickListener.onErrorClick();
                }
            }
        });
        Glide.with(this).load(R.drawable.ld).into(imageView);
    }
    public interface OnErrorClickListener{
        void onErrorClick();
    }

}
